<?php session_start();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=9" />
        <link href="style3.css" rel="stylesheet" type="text/css" />
        <title></title>
    </head>
    <body>
        <?php
        if(isset($_SESSION['lang']))
            require_once "./language_files/inviteReviewers_" . $_SESSION['lang'] . ".php";
        else
            require_once "./language_files/inviteReviewers_en.php";

        require_once 'functions.php';
        print "<h1>" . $lang['title_1'] . "</h1>";
        //the conference id from the URL
        $confid=$_GET['conference_id'];
        //the unique id in this page
        if(!isset($_SESSION['id']))
        {
            $_SESSION['id']=0;
        }
        //call make_id function which send the email to the user
        if(isset($_POST['Send']))
        {
            make_id($_POST['e_mail'],$confid);
        }
        //makes a unique id to the person organizer's sends email to
        function make_id($e_mail,$confid)
        {
            //unique id for the new user
            $_SESSION['id']=$_SESSION['id'] + 1;
            //securing the id and adding the date to give it more privacy
            $key=md5($_SESSION['id'] . getdate());
            //check if the text field is empty
            if($_POST['e_mail'] == NULL)
            {
                echo $lang['message_1'];
            }
            //check if the entered email is a proper one or not
            else
            {
                $email=mysql_safe(filter_var($e_mail,FILTER_SANITIZE_EMAIL));
                if(!filter_var($email,FILTER_VALIDATE_EMAIL))
                {

                    echo "$email " . $lang['message_2'] . " <strong>" . $lang['message_3'] . "</strong> " . $lang['message_4'] . "<br/><br/>";
                }
                else
                {
                    //inserting the request in the Request_On_Subscribe table
                    $query="INSERT INTO Request_On_Subscribe(temp_id, request_email , conference_id)
                  VALUES ('$key','$email', '$confid')";

                    mysql_query($query)
                            or die(mysql_error());
                    //send the email to the non subscribed user

                    $subject='Confo Request';
                    $message=<<<EMAIL
The Confo site asks you to become a member in the review committe, If you are interested please check the following link: http://localhost:1234/ConfO/Non_subscribed_signup.php?id=$key


EMAIL;
                    $from='mahico_92@hotmail.com';
                    $headers="From:" . $from;
                    mail($e_mail,$subject,$message,$headers);
                    echo $lang['message_5'];

                    mysql_close($con);
                }
            }
        }
        ?>
        <form method="post" action =""/>
        <table>
            <tr>
                <td>
                    <input type ="text" name ="e_mail" maxlength ="30"/>
                </td>
                <td>
                    <input type ="submit" name ="Send" value ="<?php echo $lang['button_1'];?>" />
                </td>
            </tr>
        </table>
    </body>
</html>
